package com.unc.allergyex.objects.db;

import java.util.ArrayList;

import com.unc.allergyex.helpers.ObjManager;

/** * This class represents the Component/Ingredient database
 * object.  These objects should be created from 
 * the JSON restaurant/menu result string.
 * @author Phillip
 */
public class Component {

	String name;
	String id;
	String[] allergenIds;
	
	public Component(String name, String id, String[] allergenIds) {
		this.name = name;
		this.id = id;
		this.allergenIds = allergenIds;
	}

	public String getName() {
		return name;
	}

	public String getId() {
		return id;
	}
	
	public ArrayList<Allergen> getAllergens(){
		return ObjManager.getAllergenList(allergenIds);
	}
	
	public boolean getAllergic(){
		ArrayList<String> allergic = ObjManager.getAllergicList();
		for (String allergenId : allergenIds){
			if (allergic.contains(allergenId)){
				return true;
			}
		}
		return false;
	}
}
